﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aliphant.IoC
{
    internal class ServiceCollection
    {
        private readonly Dictionary<Type, Type> _services = new();

        public void AddSingleton<TService, TImplementation>()
            where TImplementation : TService
        {
            _services[typeof(TService)] = typeof(TImplementation);
        }

        public object? GetService(Type serviceType)
        {
            if (_services.TryGetValue(serviceType, out var implType))
            {
                return Activator.CreateInstance(implType);
            }
            return null;
        }
    }
}
